import layer from 'layer-mobile';
import './index.css';

layer.msg = function (msg, opt) {
  opt = opt || {};
  if (opt.anim == 'up') {
    return this.open(
      Object.assign({
        content: msg,
        skin: 'msg',
        time: 2,
      }, opt)
    );
  } else {
    opt.anim = 'scale';
    return this.open(
      Object.assign({
        className: 'layer-limin-msg',
        content: msg,
        shade: false,
        time: 2,
      }, opt)
    );
  }
};
layer.alert = function (msg, opt) {
  return this.open(
    Object.assign({
      className: 'layer-limin',
      content: msg,
      btn: '我知道了',
    }, opt)
  );
};
layer.confirm = function (msg) {
  if (arguments[1]) {
    if (typeof arguments[1] === 'function') {
      if (arguments[2]) {
        return this.open({
          className: 'layer-limin',
          content: msg,
          btn: ['确认', '取消'],
          yes: arguments[1],
          no: arguments[2]
        });
      } else {
        return this.open({
          className: 'layer-limin',
          content: msg,
          btn: ['确认', '取消'],
          yes: arguments[1]
        });
      }
    } else {
      return this.open(
        Object.assign({
          className: 'layer-limin',
          content: msg,
          btn: ['确认', '取消'],
        }, arguments[1])
      );
    }
  } else {
    return this.open({
      className: 'layer-limin',
      content: msg,
      btn: ['确认', '取消']
    });
  }
};
layer.load = function () {
  if (typeof arguments[0] === 'string') {
    return this.open({
      type: 2,
      content: arguments[0],
      shadeClose: false
    });
  } else {
    return this.open({ type: 2, shadeClose: false });
  }
};

export default layer;
